package com.grsu.phonestation.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.grsu.phonestation.dao.InvoiceDAO;
import com.grsu.phonestation.domain.Client;
import com.grsu.phonestation.domain.Invoice;
import com.grsu.phonestation.service.InvoiceService;

@Service
@Transactional
public class InvoiceServiceImpl implements InvoiceService {


	@Autowired
	private InvoiceDAO invoiceDAO;
	
	@Override
	public void addInvoice(Invoice invoice) {
		invoiceDAO.save(invoice);

	}
	
	@Override
	public void updateInvoice(Invoice invoice) {
		invoiceDAO.update(invoice);

	}

	@Override
	public void removeInvoice(int invoiceId) {
		invoiceDAO.remove(invoiceId);

	}

	@Override
	public Invoice getInvoiceById(int invoiceId) {
		Invoice invoice = invoiceDAO.findById(invoiceId);
		return invoice;
	}

	@Override
	public List<Invoice> getInvoicesClient(Client client){
		return invoiceDAO.getInvoicesClient(client);
		
	}
	
	@Override
	public List<Invoice> listInvoices() {
		List<Invoice> invoices = invoiceDAO.findAll();
		return invoices;
	}

}
